Ref: https://hackerone.com/reports/
3656716
PR-URL: https://github.com/nodejs-private/node-private/pull/868
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
CVE-ID: CVE-2026-48930
Refs: https://hackerone.com/reports/
3656716
origin: backport, https://github.com/nodejs/node/commit/
c551a51d0c58dfc91961fb3f24c2c86af6183eca
Bug: https://nodejs.org/en/blog/vulnerability/june-2026-security-releases#embedded-nul-hostnames-can-lead-to-silent-authority-rebinding-due-to-c-string-trunc
Gbp-Pq: Topic sec
Gbp-Pq: Name CVE-2026-48930.patch
validateNumber,
validateOneOf,
validatePort,
- validateString,
+ validateStringWithoutNullBytes,
} = require('internal/validators');
const {
// Parse arguments
if (hostname) {
- validateString(hostname, 'hostname');
+ validateStringWithoutNullBytes(hostname, 'hostname');
}
if (typeof options === 'function') {
validateOneOf,
validatePort,
validateString,
+ validateStringWithoutNullBytes,
} = require('internal/validators');
const kPerfHooksDnsLookupContext = Symbol('kPerfHooksDnsLookupContext');
// Parse arguments
if (hostname) {
- validateString(hostname, 'hostname');
+ validateStringWithoutNullBytes(hostname, 'hostname');
}
if (typeof options === 'number') {
ObjectPrototypeHasOwnProperty,
RegExpPrototypeExec,
String,
+ StringPrototypeIncludes,
StringPrototypeToUpperCase,
StringPrototypeTrim,
} = primordials;
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
}
+/** @type {validateString} */
+const validateStringWithoutNullBytes = hideStackFrames((value, name) => {
+ validateString(value, name);
+ if (StringPrototypeIncludes(value, '\u0000')) {
+ throw new ERR_INVALID_ARG_VALUE(name, value, 'must be a string without null bytes');
+ }
+});
+
/**
* @callback validateNumber
* @param {*} value
validatePort,
validateSignalName,
validateString,
+ validateStringWithoutNullBytes,
validateUint32,
validateUndefined,
validateUnion,
validateNumber,
validatePort,
validateString,
+ validateStringWithoutNullBytes,
} = require('internal/validators');
const kLastWriteQueueSize = Symbol('lastWriteQueueSize');
const {
const host = options.host || 'localhost';
let { port, autoSelectFamilyAttemptTimeout, autoSelectFamily } = options;
+ validateStringWithoutNullBytes(host, 'options.host');
+
if (localAddress && !isIP(localAddress)) {
throw new ERR_INVALID_IP_ADDRESS(localAddress);
}
assert.throws(() => dnsPromises.lookup(1, {}), err);
}
+{
+ const err = {
+ code: 'ERR_INVALID_ARG_VALUE',
+ name: 'TypeError',
+ message: /The argument 'hostname' must be a string without null bytes\./,
+ };
+
+ assert.throws(() => dns.lookup('127.0.0.1\u0000.allowed.example', {}), err);
+ assert.throws(() => dnsPromises.lookup('127.0.0.1\u0000.allowed.example', {}), err);
+}
+
// This also verifies different expectWarning notations.
common.expectWarning({
// For 'internal/test/binding' module.
});
});
}
+
+{
+ assert.throws(() => {
+ net.createConnection({
+ host: '127.0.0.1\u0000.allowed.example',
+ port: 8080,
+ });
+ }, {
+ code: 'ERR_INVALID_ARG_VALUE',
+ name: 'TypeError',
+ message: /The property 'options\.host' must be a string without null bytes\./,
+ });
+}